﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;

namespace Brain
{
    public class PhysicsObject_Rectangle : IPhysicsObject2D
    {
        public object Tag { get; set; }

        public Vector2 Position
        {
            get { return Body.Position; }
            set { Body.Position = value; }
        }

        public bool Immovable
        {
            get
            {
                return Body.IsStatic;
            }
            set
            {
                Body.IsStatic = value;

                if (value)
                {
                    Body.BodyType = BodyType.Static;
                }
                else
                {
                    Body.BodyType = BodyType.Dynamic;
                }
            }
        }

        public float Mass
        {
            get
            {
                return Body.Mass;
            }
            set
            {
                Body.Mass = value;
            }
        }

        public Body Body;

        public PhysicsObject_Rectangle(World farseerWorld,
            float metersWidth, float metersHeight, float density)
        {
            Body = BodyFactory.CreateRectangle(farseerWorld,
                metersWidth, metersHeight, density);
            
            Tag = Body;
        }
    }
}
